charset is not invalid in text/javascript MIME #39505
Labels
Content:HTTP
HTTP docs
goal: accuracy
(Experimental label) Issues about inaccurate/incorrect content.
help wanted
If you know something about this topic, we would love your help!
Uh oh!
There was an error while loading. Please reload this page.
https://github.com/mdn/content/blob/main/files/en-us/web/http/guides/mime_types/index.md, rendered as https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types, is incorrect in part textjavascript:
"Per the IANA Media Types registry, RFC 9239, and the HTML specification, JavaScript content should always be served using the MIME type text/javascript. No other MIME types are considered valid for JavaScript, and using any MIME type other than text/javascript may result in scripts that do not load or run.
You may find some JavaScript content incorrectly served with a charset parameter as part of the MIME type — as an attempt to specify the character set for the script content. That charset parameter isn't valid for JavaScript content, and in most cases will result in a script failing to load."
The three links above (in the respective order):
IANA Media Types registry > the only occurrence of
text/javascript
links to https://www.iana.org/assignments/media-types/text/javascript, which reads: "Optional parameters: charset."RFC 9239 > "The charset parameter is only used when processing a Script goal source; Module goal sources MUST always be processed as UTF-8." (bold formatting is mine)
HTML specification > (the rest of this list item is one consecutive quote) > For external JavaScript resources, MIME type parameters in
Content-Type
headers are generally ignored. (In some cases thecharset
parameter has an effect.) However, for the script element's type attribute they are significant; it uses the JavaScript MIME type essence match concept.For example, scripts with their type attribute set to "text/javascript; charset=utf-8" will not be evaluated, even though that is a valid JavaScript MIME type when parsed.
<script type="...">
tag in HTML source. Specifically, "their type" links to HTML definition oftype
attribute of<script>
element. NOT MIME as served by web server (or as specified indata:
URLs).I'm willing to provide a pull request.
The text was updated successfully, but these errors were encountered: